package com.biz.primus.ms.oms.api;

import com.biz.primus.base.vo.PageResult;
import com.biz.primus.model.oms.vo.*;
import com.biz.primus.ms.oms.service.core.OrderInterceptService;
import com.biz.primus.ms.oms.service.delivery.FlashDeliveryMonitoringServiceImpl;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * @author LGJ
 * @date  2017/11/25
 */
@RestController
@RequestMapping("soa/managementMonitor")
public class OmsManagementMonitorController {

    @Autowired
    private OrderInterceptService orderInterceptService;

    @Autowired
    private FlashDeliveryMonitoringServiceImpl flashDeliveryMonitoringService;

    @PostMapping("saveOrderIntercept")
    @ApiOperation("保存拦截规则")
    public void saveOrderIntercept(@RequestBody List<OrderInterceptVo> orderInterceptVo){
        orderInterceptService.saveOrderIntercept(orderInterceptVo);
    }

    @GetMapping("delOrderIntercept")
    @ApiOperation("删除拦截规则")
    public void delOrderIntercept(@RequestParam("id") String id){
        orderInterceptService.delOrderIntercept(id);
    }

    @GetMapping("setState")
    @ApiOperation("设置拦截启用状态")
    public void setState(@RequestParam("id") String id,@RequestParam("state")boolean state){
        orderInterceptService.setState(id,state);
    }

    @PostMapping("findAllOrderIntercept")
    @ApiOperation("查询所有订单拦截规则")
    public PageResult<OrderInterceptVo> findAllOrderIntercept(OrderInterceptQueryVo orderInterceptQueryVo){
        return orderInterceptService.findAllOrderIntercept(orderInterceptQueryVo);
    }

    @PostMapping("queryTimeoutRecords")
    @ApiOperation("闪送订单监控列表查询")
    public PageResult<OmsTimeoutRecordVo> queryTimeoutRecords(@RequestBody  TimeoutRecordQueryVo timeoutRecordQueryVo){
        return flashDeliveryMonitoringService.queryTimeoutRecords(timeoutRecordQueryVo);
    }

    @PostMapping("handleRecord")
    @ApiOperation("处理超时订单")
    public void handleRecord(TimeoutRecordHandleRequest timeoutRecordHandleRequest){
        flashDeliveryMonitoringService.handleRecord(timeoutRecordHandleRequest);
    }

}
